package oakclub.entity;

import java.util.HashMap;
import java.util.Map;

public class GenderEntity extends BaseEntity
{
    private int id;

    public enum Gender
    {
        UNKNOWN(-1, "Unknown"), FEMALE(0, "Female"), MALE(1, "Male"), BISEXUAL(2, "Bisexual");

        private final int id;
        private final String name;

        private Gender(int id, String name)
        {
            this.id = id;
            this.name = name;
        }

        public int getId()
        {
            return this.id;
        }

        public String getName()
        {
            return this.name;
        }

        private static final Map<Integer, Gender> lookup = new HashMap<>();

        static
        {
            for(Gender gender : Gender.values())
            {
                lookup.put(gender.id, gender);
            }
        }

        public static String getName(int id)
        {
            Gender gender = lookup.get(id);
            if(gender == null)
            {
                return UNKNOWN.getName();
            }

            return gender.getName();
        }
    }

    public GenderEntity()
    {

    }

    public GenderEntity(int id)
    {
        this.id = id;
    }

    public int getId()
    {
        return id;
    }

    public void setId(int id)
    {
        this.id = id;
    }

    public String getName()
    {
        return Gender.getName(this.id);
    }
}
